package com.ccp.dev.qbdms.webservice.cxf;

import com.ccp.dev.qbdms.webservice.CommonWebService;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import javax.xml.ws.Endpoint;

/**
 * cxf配置类
 * @author y
 */
@Configuration
public class CxfConfig {

    @Resource
    CommonWebService commonWebService;

/*
    @Bean //可以自定义配置起始路径
    public ServletRegistrationBean dispatcherServletForWebservice(){
        return new ServletRegistrationBean(new CXFServlet(), "/services/*");
    }
*/

    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus(){
        return  new SpringBus();
    }

    /** JAX-WS **/
    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), commonWebService);
        endpoint.publish("/CommonWebService");
        return endpoint;
    }
}
